import Axios from "axios";
// import VueCookies from 'vue-cookies';

const state = () => ({
    // 活动分类
    classification: {
        showPicker: false, // 弹出层状态
        value: '请选择', // 分类名
    },
    // 图片
    fileList: [],
    // 活动数据
    activity_data: {
        classification_id: null, // 分类ID
        title: '', // 活动标题
        fileList: [], // 图片
        other_text: '', // 其他
        bright_spot: '', // 活动亮点
        content: '', // 活动内容
        // 活动人数
        amount: {
            min: 1,
            max: 1,
        }, 
        // 时间
        time: {
            start: null,
            end: null,
        },
        // 地址
        address: {
            type: '2', // A线上 or B线下
            cityList: '', // 城市
            cityList_id: null, // 城市ID
            cityList_text: '', // 地址详细
        },
    },
})

// getters
const getters = {

}

// actions
const actions = {

}

// mutations
const mutations = {
    // 保存活动详细
    save(state, payload) {
        state.activity_data.bright_spot = payload.bright_spot;
        state.activity_data.content = payload.content;
        // console.log('测试');
    },
    // 保存标题
    save_title(state, payload) {
        state.activity_data.title = payload;
    },
    // 保存分类
    save_classify(state, payload) {
        state.classification.value = payload.name;
        state.classification.showPicker = payload.showPicker;
        state.activity_data.classification_id = payload.id;
    },
    // 保存图片
    save_img(state, payload) {
        state.activity_data.fileList = payload;
    },
    // 保存人数
    save_amount(state, payload) {
        state.activity_data.amount.min = payload.min;
        state.activity_data.amount.max = payload.max;
    },
    // 其他
    save_text(state, payload) {
        state.other_text = payload.other_text;
    },
    // 保存时间
    save_time(state, payload) {
        state.activity_data.time = payload;
    },
    // 保存地址
    save_address(state, payload) {
        state.activity_data.address = payload;
    },
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}


/*
export default {
    state: () => ({
       //  t: 0
    }),
    getters:{
    },
    mutations: {
        test () {
            console.log('store的测试');
        },
        login(state,Payload) {
            Axios
            .get('/api/user/login/',{
                params: {
                    username: Payload.username,
                    password: Payload.password
                }
            })
        }
    },
    actions: {
    },
    modules: {
    }
}
*/

